home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / misc / xconf2.c < prev   
C/C++ Source or Header  |  1996-06-25  |  3KB  |  96 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <assert.h>
  4. #include "../dialog/dialog.h"
  5. #include "misc.h"
  6.  
  7. /*
  8.     Input a string or a password.
  9.     Return 0 if the input is successful (no Escape, no Cance).
  10.     Return -1 if anything else.
  11. */
  12. static MENU_STATUS xconf_inputbox0 (
  13.     const char *title,    // Window's title
  14.     const char *explan,    // Explanation of the selection to do
  15.     HELP_FILE &helpfile,    // Help file or help_nil
  16.     char buffer[MAX_LEN+1],    // Buffer for input.
  17.     MENU_STATUS (*fct)(const char *, const char *, const char *, char buffer[MAX_LEN+1]))
  18. {
  19.     dialog_clear();
  20.     return (*fct) (title,explan    ,helpfile.getpath(),buffer);
  21. }
  22.  
  23. /*
  24.     Input a string in a box.
  25. */
  26. MENU_STATUS xconf_inputbox (
  27.     const char *title,    // Window's title
  28.     const char *explan,    // Explanation of the selection to do
  29.     HELP_FILE &helpfile,    // Help file or help_nil
  30.     char buffer[MAX_LEN+1])    // Buffer for input.
  31. {
  32.     return xconf_inputbox0 (title,explan,helpfile,buffer,dialog_inputbox);
  33. }
  34. /*
  35.     Input a password in a box.
  36.     Return 0 if the input is successful (no Escape, no Cance).
  37.     Return -1 if anything else.
  38. */
  39. MENU_STATUS xconf_inputpass (
  40.     const char *title,    // Window's title
  41.     const char *explan,    // Explanation of the selection to do
  42.     HELP_FILE &helpfile,    // Help file or help_nil
  43.     char buffer[MAX_LEN+1])    // Buffer for input.
  44. {
  45.     html_setpopup();
  46.     return xconf_inputbox0 (title,explan,helpfile,buffer,dialog_inputpass);
  47. }
  48. /*
  49.     Multiple field dialog. See dialog/multi_inputbox.
  50.  
  51.     Return MENU_ACCEPT, MENU_CANCEL or MENU_ESCAPE
  52.  
  53.     If edit != 0, minstr[] will be modified only if the user select OK (and
  54.     the function return 0).
  55.  
  56.     If edit == 0, minstr[] will be either set to '\0' or will contain the
  57.     input of the user if he selected OK.
  58.  */
  59. MENU_STATUS xconf_multiinp(
  60.     const char *title,            // Main title
  61.     const char *intro,            // Mini help describing the purpose
  62.                                 // of the dialog
  63.     HELP_FILE &helpfile,        // Help file or help_nil
  64.     const char *prompts[],        // Title of each field
  65.     char minstr[][MAX_LEN+1],    // Input field
  66.     int nbfield,                // Number of input field
  67.     int edit,                    // Edit current value or reset to '\0'
  68.     int nof)                    // Start editing on which field
  69. {
  70.     DIALOG dia;
  71.     for (int i=0; i<nbfield; i++){
  72.         if (!edit) minstr[i][0] = '\0';
  73.         dia.newf_str (prompts[i],minstr[i],MAX_LEN);
  74.     }
  75.     return dia.edit (title,intro,helpfile.getpath(),nof);
  76. }
  77.  
  78. /*
  79.     Display a dialog box with a list of options that can be turned on or off
  80.     Wrapper for HELP_FILE management.
  81. */
  82. int xconf_checklist(
  83.     const char *title,
  84.     const char *prompt,
  85.     HELP_FILE &helpfile,        // Help file or help_nil
  86.     int list_height,
  87.     int item_no,
  88.     char **items,
  89.     char *status)        /* Array of flags indicating if items[x] is */
  90.                         /* selected */
  91. {
  92.     return dialog_checklist (title,prompt,helpfile.getpath()
  93.         ,list_height,item_no,items,status);
  94. }
  95.  
  96.